#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''=================================================
@Project -> File   ：js逆向 -> asyncio新写法
@IDE    ：PyCharm
@Author ：王启俊
@Date   ：2024-03-30 16:54
@Desc   ：
=================================================='''

import asyncio
import time


async def foo(i):
    print(f'任务{i} start')
    await asyncio.sleep(i)
    print(f'任务{i}  end')
    return i*i

async def main():

    task1 = [
        asyncio.create_task(foo(1)),
        asyncio.create_task(foo(2)),
        asyncio.create_task(foo(3)),
    ]
    await asyncio.wait(task1)

if __name__ == '__main__':
    start = time.time()
    asyncio.run(main())
    print(start - time.time())